<?php
namespace api\common\controllers;

use Yii;
use yii\rest\ActiveController;
use yii\filters\auth\HttpBearerAuth;
use yii\helpers\ArrayHelper;

/**
 * base controller rest
 * 负责集中控制授权控制
 */
class BaseController extends ActiveController
{
    /**
     * 附加到此控制器中的行为列表.
     * 这里主要是验证方法执行前先执行token验证.
     * @return array 返回行为附加到该组件的列表.
     */
    public function behaviors()
    {
        $behaviors = parent::behaviors();
        $behaviors = ArrayHelper::merge([
            'corsFilter' => [
                'class' => \yii\filters\Cors::className(),
                'cors' => [
                    'Origin' => ['*'],
                    'Access-Control-Request-Method' => ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
                    'Access-Control-Request-Headers' => ['*'],
                ],
            ],
        ], $behaviors);

        unset($behaviors['authenticator']);

        return $behaviors;
    }


}
